/*
 * This is GPL v2 licensed code. See the file LICENSE in the
 * source distribution, or www.gnu.org/copyleft/gpl.html, for
 * more information.
 *
 * Copyright (C) by Håkan Lindqvist 2006, 2007
 */

package PolicyAlgebra.Type;

/** 
 * This class implements the ability to attach a comment to
 * a named atom; most types are commentable.
 */
public abstract class Commentable extends NamedAtom {

	private String comment;


	/** 
	 * Constructor, automatically adds "" as comment. 
	 * 
	 * @param name The name for this commentable.
	 */
	public Commentable(String name) {
		this(name, "");
	}


	/** 
	 * Constructor. 
	 * 
	 * @param name The name for this commentable.
	 * @param comment The commetn to attach to the commentable.
	 */
	public Commentable(String name, String comment) {
		super(name);
		this.comment = comment;
	}


	/** 
	 * Constructor. 
	 * 
	 * @param name The name for this commentable.
	 * @param comment The type to attach to the commentable.
	 */
	public Commentable(String name, Type type) {
		super(name, type);
		this.comment = "";
	}


	/** 
	 * Constructor. 
	 * 
	 * @param name The name for this commentable.
	 * @param type The type to attach to the commentable.
	 * @param comment The comment to attach to the commentable.
	 */
	public Commentable(String name, Type type, String comment) {
		super(name, type);
		this.comment = comment;
	}


	/** 
	 * Accessor for the comment. 
	 * 
	 * @return The comment attached to this object.
	 */
	public String getComment() {
		return comment;
	}


	/** 
	 * Custom string transformation method. 
	 * 
	 * @return The string representation of this commentable.
	 */
	public String toString() {
		return super.toString() + " (" + comment + ")";
	}
}
